package pairwise_model;
import preprocess.*;
import java.util.*;
public class Pairwise_Bigram {
	public int CommonBigram(List<String> bigrams1, List<String> bigrams2){
		int score = 0;
		if(bigrams1 == null || bigrams2 == null || bigrams1.size()==0 || bigrams2.size()==0)
			return score;
		HashMap<String,Integer> bigram_hash1 = new HashMap<String,Integer>();
		Text_Clean cleanser = new Text_Clean();
		for(String bigram: bigrams1){
			String s[] = bigram.split(" ");
			if(s[0].length() <=1 || cleanser.Is_StopWord(s[0]) || s[1].length()<=1 || cleanser.Is_StopWord(s[1]))
				continue;
			bigram_hash1.put(bigram.toLowerCase(), bigram_hash1.size());
		}
		for(String bigram: bigrams2){
			if(bigram_hash1.containsKey(bigram.toLowerCase()))
				score++;
		}
		return score;
	}
}
